package com.audaque.jadmin.system.action;

import java.util.List;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.audaque.jadmin.common.action.BaseAction;
import com.audaque.jadmin.system.model.Role;
import com.audaque.jadmin.system.model.User;
import com.audaque.jadmin.system.service.UserService;

/**
 * @Description :
 * @FileName: UserAction.java
 * @Author :WeiHui.Zhang
 * @Data : 2015年9月23日 上午8:52:16
 * @Version:V1.00
 */
@Controller
@RequestMapping(UserAction.PATH)
public class UserAction extends BaseAction {

	protected final static String PATH = "system/user";

	@Autowired
	private UserService userService;
	
	@Override
	protected String getJspPathPrefix() {
		return PATH;
	}

	@RequestMapping("/index")
	public String index(HttpServletRequest request, HttpServletResponse response) {
		User user = getCurrentUser();
		System.out.println(user);
		return "system/index";
	}
	
	@RequestMapping("roles")
	@ResponseBody
	public List<Role> getUserRoles(HttpServletRequest request) {

		Integer userId = getCurrentShiroUser().getId();

		List<Role> roles = userService.queryUserRoles(userId);
		
		return roles;
	}

}
